<template>
  <div class="chart-container">
    <div class="chart-title">舆情热度趋势</div>
    <div ref="chart" class="chart"></div>
  </div>
</template>

<script>
import * as echarts from 'echarts'

export default {
  name: 'SentimentTrendChart',
  data() {
    return {
      chart: null
    }
  },
  mounted() {
    this.initChart()
  },
  methods: {
    initChart() {
      this.chart = echarts.init(this.$refs.chart)
      
      const option = {
        tooltip: {
          trigger: 'axis'
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: ['1月', '2月', '3月', '4月', '5月', '6月'],
          axisLabel: { color: '#fff' }
        },
        yAxis: {
          type: 'value',
          axisLabel: { color: '#fff' }
        },
        series: [{
          name: '舆情量',
          type: 'line',
          data: [1200, 2000, 1500, 3000, 2000, 1800],
          areaStyle: {
            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
              offset: 0,
              color: 'rgba(80,141,255,0.39)'
            }, {
              offset: 1,
              color: 'rgba(80,141,255,0.1)'
            }])
          },
          lineStyle: {
            color: '#508dff'
          },
          itemStyle: {
            color: '#508dff'
          }
        }]
      }
      
      this.chart.setOption(option)
    }
  },
  beforeDestroy() {
    if (this.chart) {
      this.chart.dispose()
    }
  }
}
</script>

<style lang="scss" scoped>
.chart-container {
  background: rgba(255, 255, 255, 0.1);
  padding: 15px;
  border-radius: 8px;
  
  .chart-title {
    font-size: 16px;
    margin-bottom: 15px;
  }
  
  .chart {
    height: 250px;
  }
}
</style> 